#include "MultiBlock2D.h"

MultiBlock2D::MultiBlock2D(int neededSizeX, int neededSizeY, int stride)
{
	this->stride = stride;
	numX = neededSizeX / StrideX();
	numY = neededSizeY / StrideY();

	lastSizeX = neededSizeX % StrideX();
	lastSizeY = neededSizeY % StrideY();

	if (lastSizeX != 0)
		numX++;
	else
		lastSizeX = StrideX();
	if (lastSizeY != 0)
		numY++;
	else
		lastSizeY = StrideY();
}

dim3 MultiBlock2D::GetBlockSize(int x, int y)
{
	return dim3((x + 1 == numX) ? lastSizeX : StrideX(), (y + 1 == numY) ? lastSizeY : StrideY());
}
